import { request } from "@utils/request";
import {
  getCurrentOrganizationId
} from '@/utils/util.js'
const api = {
    getDataProjectTeam: "/project/Windchill/servlet/rest/hzero/pmgt/team/getDataProjectTeam",
    getAllRoles: "/project/Windchill/servlet/rest/hzero/pmgt/team/getAllRoles",
    getProjectRole: "/project/Windchill/servlet/rest/hzero/pmgt/team/getProjectRole",
    addRoleTeamMember: "/project/Windchill/servlet/rest/hzero/pmgt/team/addRoleTeamMember",
    removeRoleTeamMember: "/project/Windchill/servlet/rest/hzero/pmgt/team/removeRoleTeamMember",
    saveRoleEdit: "/project/Windchill/servlet/rest/hzero/pmgt/team/saveRoleEdit",
    copyProjectTeam: "/project/Windchill/servlet/rest/hzero/pmgt/team/copyProjectTeam",
    getRolePermissionConfig: "/project/Windchill/servlet/rest/hzero/pmgt/team/getRolePermissionConfig",
    getPermissionConfig: "/project/Windchill/servlet/rest/hzero/pmgt/team/getPermissionConfig",
    savePermissionEdit: "/project/Windchill/servlet/rest/hzero/pmgt/team/savePermissionEdit",
    exportProjectTeam: "/project/Windchill/servlet/rest/hzero/pmgt/team/exportProjectTeam",
    importProjectTeam: "/project/Windchill/servlet/rest/hzero/pmgt/team/importProjectTeam",
    getProjectResources: "/project/Windchill/servlet/rest/hzero/pmgt/team/getProjectResources",
    downTeamTemplate:"/project/Windchill/servlet/rest/hzero/pmgt/team/downTeamTemplate",
    replaceTeamMember:"/project/Windchill/servlet/rest/hzero/pmgt/team/replaceTeamMember",
    startTeamReviewWF:"/project/Windchill/servlet/rest/hzero/pmgt/team/startTeamReviewWF",
    teamReviewType:"/project/Windchill/servlet/rest/hzero/pmgt/team/teamReviewType",
    canEditTeam:"/project/Windchill/servlet/rest/hzero/pmgt/team/canEditTeam",
    startTeamChangeWF:"project/Windchill/servlet/rest/hzero/pmgt/team/startTeamChangeWF",
}
// export const exportUrl = api.exportProjectTeam
// export const importUrl = api.importProjectTeam 
/*
 * 功能: 获取项目团队数据 
 * params: {userId:用户ID,oid:项目id}
 * 返回:  
 * @Last Modified time: 2021-07-05 11:48:04 
 */
export function getDataProjectTeam(params) {
    return request({
      url: api.getDataProjectTeam,
      method: "post",
      data: params,
    });
}
// 获取后台角色集合
export function getAllRoles(params) {
    return request({
      url: api.getAllRoles,
      method: "post",
      data: params,
    });
}
// 获取项目团队角色
export function getProjectRole(params) {
    return request({
      url: api.getProjectRole,
      method: "post",
      data: params,
    });
}
// 为角色添加团队成员
export function addRoleTeamMember(params) {
    return request({
      url: api.addRoleTeamMember,
      method: "post",
      data: params,
    });
} 
// 移除角色下成员
export function removeRoleTeamMember(params) {
    return request({
      url: api.removeRoleTeamMember,
      method: "post",
      data: params,
    });
}
// 保存角色编辑
export function saveRoleEdit(params) {
    return request({
      url: api.saveRoleEdit,
      method: "post",
      data: params,
    });
}
// 复制其他项目团队
export function copyProjectTeam(params) {
    return request({
      url: api.copyProjectTeam,
      method: "post",
      data: params,
    });
}
// 获取角色已有权限配置
export function getRolePermissionConfig(params) {
    return request({
      url: api.getRolePermissionConfig,
      method: "post",
      data: params,
    });
}
// 获取后台权限配置
export function getPermissionConfig(params) {
    return request({
      url: api.getPermissionConfig,
      method: "post",
      data: params,
    });
}
// 保存权限编辑
export function savePermissionEdit(params) {
    return request({
      url: api.savePermissionEdit,
      method: "post",
      data: params,
    });
}
// 导出
export function exportProjectTeam(params) {
    return request({
      url: api.exportProjectTeam,
      method: "post",
      data: params,
      responseType: 'blob' //服务器返回的数据类型
    });
}
// 导入
export function importProjectTeam(params) {
    return request({
      url: api.importProjectTeam,
      method: "post",
      data: params,
    });
}
// 获取项目资源列表
export function getProjectResources(params) {
    return request({
      url: api.getProjectResources,
      method: "post",
      data: params,
    });
}
//下载团队成员模板
export function downTeamTemplate(){
  return request({
    url: api.downTeamTemplate,
    method: "post",
    data: '',
    responseType: 'blob' //服务器返回的数据类型
  });
}
//替换团队成员
export function replaceTeamMember(params){
  return request({
    url: api.replaceTeamMember,
    method: "post",
    data: params
  });
}
// 编辑保存使用人员
export function saveRecentUser(params) {
  return request({
    url: `indv/v1/${getCurrentOrganizationId()}/user-staffs`,
    method: 'put',
    data: params,
  })
}
// 启动项目团队流程
export function startTeamReviewWF(params) {
  return request({
    url: api.startTeamReviewWF,
    method: "post",
    data: params,
  });
}
//  团队评审类型
export function teamReviewType(params) {
  return request({
    url: api.teamReviewType,
    method: "post",
    data: params,
  });
}
//  判断功能按钮是否能编辑
export function canEditTeam(params) {
  return request({
    url: api.canEditTeam,
    method: "post",
    data: params,
  });
}
//  团队变更流程
export function startTeamChangeWF(params) {
  return request({
    url: api.startTeamChangeWF,
    method: "post",
    data: params,
  });
}